package com.book.controller;

import com.book.entity.Role;
import com.book.service.RoleService;
import com.book.util.JsonResult;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author SuperYu  2024/6/24
 */
@RestController
@Slf4j
public class RoleController {

    @Resource
    RoleService roleService;


    @GetMapping("/api/getRole")
    public JsonResult<List<Role>> getRole(String userName) {

        List<Role> list = roleService.findRoleByUserName(userName);

        return JsonResult.ok(list);
    }

    @GetMapping("/api/role/showAll")
    public JsonResult<PageInfo<Role>> showAll(int pageNum, int pageSize) {

        PageInfo<Role> pageInfo = roleService.findAllRole(pageNum, pageSize);

        return JsonResult.ok(pageInfo);
    }

}


